﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewAI.FSM.SocketConnectFSM
{
    public class SendRegistrationState:State<AIClientSocket>
    {
        public override void Enter(AIClientSocket entity)
        {
            entity.ClientSocket.Send(Encoding.UTF8.GetBytes(GetRegistrationSendText()));
        }

        private string GetRegistrationSendText()
        {
            string json = RegistrationJson.Registration;
            json = json.Replace("【ID】", GV.OurTeam.TeamID.ToString());
            json = json.Replace("【Name】", GV.OurTeam.TeamName);
            return FillJsonLength(json);
        }

        private string FillJsonLength(string json)
        {
            for (int i = json.Length; i < 5; i++)
                json = "0" + json;
            return json;
        }
    }
}
